from pathlib import Path

import pytest

from storage.compress import compress_file, decompress_file


@pytest.mark.parametrize('split', [1, 2, 3, 4, 5, 6, 7, 8])
def test_convert_to_compressed_file(input_path: Path, output_path: Path, split: int):
    compress_file(input_path, output_path, split=split)
    decompress_file(output_path / (input_path.name + '.meta'), output_path)
    assert input_path.read_bytes() == (output_path / input_path.name).read_bytes()


@pytest.mark.parametrize('split', [1, 2, 4])
@pytest.mark.benchmark
def test_benchmark_convert_to_compressed_file(benchmark, input_path, output_path, split):
    benchmark(compress_file, input_path, output_path, split=split)
